#include<cstdio>
#include<cstring>
const int maxn=100010;
const int MAX=2100000000;
int a[maxn],s[maxn],r[maxn],l[maxn],w[maxn];
long long c[maxn];
int n,t;
int low(int x)
{
	return x&(x^(x-1));
}
void add(int x,int v)
{
	while(x<=n)
	{
		c[x]+=v;
		x+=low(x);
	}
}
long long sum(int x)
{
	long long  ans=0;
	while(x>0)
	{
		ans+=c[x];
		x-=low(x);
	}
	return ans;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		add(i,a[i]);
	}
	a[0]=MAX;a[n+1]=-MAX;
	w[1]=1;s[1]=a[1];t=1;
	for(int i=2;i<=n+1;i++)
	{
		int x=a[i];
		while(t>0&&x<s[t])
		{
			r[w[t]]=i-1;
			t--;
		}
		t++;
		s[t]=x;w[t]=i;
	}
	a[0]=-MAX;a[n+1]=MAX;
	t=1;s[1]=a[n];w[1]=n;
	for(int i=n-1;i>=0;i--)
	{
		int x=a[i];
		while(t>0&&x<s[t])
		{
			l[w[t]]=i+1;
			t--;
		}
		t++;
		s[t]=x;w[t]=i;
	}
	long long ans=-1;
	int le,ri;
	for(int i=1;i<=n;i++)
		if(ans<a[i]*(sum(r[i])-sum(l[i]-1)))
		{
			ans=a[i]*(sum(r[i])-sum(l[i]-1));
			le=l[i];ri=r[i];
		}
	printf("%lld\n%d %d\n",ans,le,ri);
	return 0;
}


